import TextureRenderUtils from "../TextureRenderUtils";
import Resolution from "../Resolution";


const { ccclass, property } = cc._decorator;

@ccclass
export default class CaptureComp extends cc.Component {
    @property(cc.Camera)
    camera: cc.Camera = null;
    //最后需要这个node生成图片需要的数据
    @property(cc.Node)
    renderNode: cc.Node = null;
    protected textureHelper: TextureRenderUtils = new TextureRenderUtils();
    start() {
        this.camera.zoomRatio *= Resolution.getFDRatio()
        console.log(" CaptureComp this.camera.zoomRatio ", this.camera.zoomRatio)
        this.textureHelper.init(this.camera, this.renderNode)
    }

    getTextureHelper(){
        return this.textureHelper;
    }

    getPixelFormat(){
        return this.textureHelper.getPixelFormat()
    }

    getDataUrl() {
        return this.textureHelper.getDataUrl()
    }

    getData(){
        return this.textureHelper.getData()
    }

    render(){
        this.textureHelper.render();
    }

    getTextureInfo(){
        return this.textureHelper.getTextureInfo()
    }
}